package com.skycode7.servlet;

import com.skycode7.bean.AdminBean;
import com.skycode7.dao.AdminDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/admin.html")
public class AdminServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
            req.setCharacterEncoding("UTF-8");
            String sq = req.getParameter("page");
            int page = 1;
            String username = req.getParameter("username");
            String password = req.getParameter("password");
            if (sq == null && sq.equals("")){
                page = Integer.parseInt(sq);
            }
        AdminDao admindao = new AdminDao();
            List<AdminBean> list = AdminDao.getAdminList(page);
            req.setAttribute("list",list);
            req.getRequestDispatcher("WEB-INF/admin.jsp");
        }
    }

